/***********************************************
 This file is part of redia-library-app-ios.
 
 Copyright (c) 2012, 2013 Redia A/S
 
 Redia-library-app-ios is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 Redia-library-app-ios is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with redia-library-app-ios.  If not, see <http://www.gnu.org/licenses/>.
 
 *********************************************** */


#import <Foundation/Foundation.h>
#import "InfoEditor.h"
#import "InfoSource.h"
#import "InfoComment.h"
#import "InfoMedia.h"
#import "InfoMediaEncoding.h"
#import "InfoGeoLocation.h"
#import "TBXML+Compression.h"
#import "TBXML.h"
#import "InfoObject3.h"

typedef enum infoobjecttype {
	INFOOBJECT_TYPE_STANDARD,
	INFOOBJECT_TYPE_UNKNOWN,
	INFOOBJECT_TYPE_ARRANGEMENT,
	INFOOBJECT_TYPE_VOTE
} InfoObjectType;

typedef enum infoobjectparserstate {
	PARSER_STATE_UNKNOWN,
	PARSER_STATE_UNPARSED,
	PARSER_STATE_UNPARSED_WITH_ID,
	PARSER_STATE_PARSE_SUCCESS,
	PARSER_STATE_PARSER_ERROR
	
	

} InfoObjectParserState;

@interface InfoObject : NSObject {
	NSMutableDictionary *translatedInfoObjects; ///< dictionary from NSString* to InfoObject3*
	NSString *xmlData;
	int protocol;
	InfoObjectParserState parserState;
	InfoObjectType infoObjectType;
	
	NSString* infoObjectId;
}

@property (nonatomic, strong) NSMutableDictionary *translatedInfoObjects;
@property (nonatomic, strong) NSString *xmlData;
@property (nonatomic, copy) NSString* infoObjectId;

//- (id)initWithUrl:(NSString *)url;
- (id)initWithXmlString:(NSString *)xmlData;
- (void)parse;
- (NSString *)getId;
- (void)setId:(NSString*)anObjectId;
- (NSString *)getHeadline:(NSString *)lang;
- (NSString *)getSubHeadline:(NSString *)lang;
- (NSString *)getBody:(NSString *)lang;
- (NSString*)getBodyWithConvertedPTags:(NSString *)lang; ///< Utility that adds extra nbsp at end of p tags for better formattin g

- (NSArray *)getLanguages; ///< Array of strings with language IDs
- (NSString *)getTemplate:(NSString *)language;
- (NSArray *)getMedia:(NSString *)language; ///< Array of InfoMedia instances
- (InfoMedia *)getFirstVideoMedia:(NSString *)language;
- (InfoMedia *)getFirstImageMedia:(NSString *)language;
+ (NSString*)getUrlForVideoMedia:(InfoMedia*)io withEncoding:(NSString*)enc;
- (NSArray *)getTags:(NSString *)language;
- (NSArray *)getComments:(NSString *)language;
- (NSString *)getCategory:(NSString *)language;
- (InfoObjectType)getType;
- (NSArray *)getUrls:(NSString *)language;
- (InfoEditor *)getEditor:(NSString *)language;
- (InfoSource *)getSource:(NSString *)language;
- (NSDictionary *)getMetaData:(NSString *)language; ///< Dictionary of strings to strings
- (NSString*)getMetaData:(NSString *)language forKey:(NSString*)key;
- (NSArray *)getLocations:(NSString *)language; ///< Array of strings with locations
- (NSArray *)getGeoLocations:(NSString *)language;
- (NSString *)getFirstLanguage;
- (NSArray *)getChildInfoObjects; ///< Array of strings with ids
- (NSArray *)getChildInfoObjects:(NSString *)language; ///< Array of strings with ids
- (NSArray *)getChannels:(NSString *)language;
- (NSDictionary *)getChannelIDs:(NSString *)language;
- (int)getProtocol;

- (void)handleVersion3InfoObject:(TBXMLElement *)elementElement infoObject3:(InfoObject3 *)infoObject3 language:(NSString *)language;

- (NSDate*) getBeginDate:(NSString *)language;

- (NSArray*) getVoteOptions:(NSString *)language;

+ (NSString*) unescapeString:(NSString*)string;
+ (NSDate*)parseDate:(NSString*)datestring;

@end
